package com.gf.common.bean;

import java.util.LinkedList;
import java.util.List;

/**
 * 队列<br>
 * @author zhuguifeng guifeng.net@gmail.com
 * @version 创建时间：2012-10-4 下午9:37:01
 */
public class Queue {

	@SuppressWarnings("rawtypes")
	private List list;

	@SuppressWarnings({ "rawtypes" })
	public Queue() {
		 //线程安全导致效率低
		//list = Collections.synchronizedList(new LinkedList());
		list = new LinkedList();
	}

	/**
	 * 增加到队列里
	 * 
	 * @param obj
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public boolean add(Object obj) {
		if (obj != null) {
			return list.add(obj);
		}
		return false;
	}

	/**
	 * 超出抛出异常
	 * 
	 * @return
	 */
	public Object poll() {
		return list.remove(0);
	}

	/**
	 * 空
	 * 
	 * @return
	 */
	public boolean isEmpty() {
		return list.isEmpty();
	}

	/**
	 * 容量
	 * 
	 * @return
	 */
	public int size() {
		return list.size();
	}

	public void clear() {
		list.clear();
	}
}
